package com.neuedu.yyzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neuedu.yyzx.entity.NurseRecords;
import com.neuedu.yyzx.mapper.NurseRecordsMapper;
import com.neuedu.yyzx.service.INurseRecordsService;
import org.springframework.stereotype.Service;

@Service
public class NurseRecordsImpl extends ServiceImpl<NurseRecordsMapper, NurseRecords> implements INurseRecordsService {

    public boolean updateAll(NurseRecords nurseRecords) {
        UpdateWrapper updateWrapper = new UpdateWrapper();

        updateWrapper.set("customer_name", nurseRecords.getCustomerName());
        updateWrapper.set("nursing_project", nurseRecords.getNursingProject());
        updateWrapper.set("nursing_time", nurseRecords.getNursingTime());
        updateWrapper.set("number", nurseRecords.getNumber());
        updateWrapper.set("content", nurseRecords.getContent());
        updateWrapper.set("nursing_staff", nurseRecords.getNursingStaff());
        if(nurseRecords.getContent()!=null){
            updateWrapper.set("content", nurseRecords.getContent());
        }
        if (nurseRecords.getNursingStaff()!=null){

            updateWrapper.set("nursing_staff",  nurseRecords.getNursingStaff());
        }


        updateWrapper.eq("id", nurseRecords.getId());

        int success = getBaseMapper().update(nurseRecords, updateWrapper);

        return success>0;
    }
}